package com.dyh.demo.listenner;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.dyh.demo.controller.EmpController;
import com.dyh.demo.dao.EmpMapper;
import com.dyh.demo.entity.Emp;

/**
 * @author dyh
 * @version 1.0
 * Create by 2022/10/14 11:55
 */
public class EmpListenner extends AnalysisEventListener<Emp> {
    private EmpController empController;
    private EmpMapper empMapper;
    private Emp emp;
    private int i = 1;

    public EmpListenner() {
    }


    public EmpListenner(EmpMapper empMapper) {
        System.out.println("有参构造函数");
        this.empMapper = empMapper;
    }


    @Override
    public void invoke(Emp emp, AnalysisContext analysisContext) {
        System.out.println(emp);
        System.out.println(analysisContext);
        System.out.println("已到invoke:"+i+"次");
        empMapper.insert(emp);
        i++;
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        System.out.println("已到doAfterAllAnalysed");
    }


}
